import threading

num = 0
def add():
    global num
    for _ in range(1000000):
        num+=1


def sub():
    global num
    for _ in range(1000000):
        num -= 1

if __name__ == '__main__':

    t1 = threading.Thread(target=add)
    t2 = threading.Thread(target=sub)

    t1.start()
    t2.start()
    t1.join()
    t2.join()

    # 循环次数超过一定数量后 num最后的值不等于0
    print(num)